package com.digital.smartgrow.service.datacenter.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.digital.smartgrow.dto.datacenter.SysDictDataPageDTO;
import com.digital.smartgrow.entity.datacenter.SysDictData;
import com.digital.smartgrow.dao.datacenter.SysDictDataMapper;
import com.digital.smartgrow.service.datacenter.SysDictDataService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 字典数据表 服务实现类
 * </p>
 *
 * @author sunyuechao
 * @since 2022-07-11
 */
@Service
public class SysDictDataServiceImpl extends ServiceImpl<SysDictDataMapper, SysDictData> implements SysDictDataService {

    @Override
    public Object getListByPage(SysDictDataPageDTO pageDTO) {
        Page<SysDictData> page = new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize());
        QueryWrapper<SysDictData> queryWrapper = new QueryWrapper<>();
        //id
       // queryWrapper.eq(StringUtils.isNotBlank(pageDTO.getDict_code()+""), "dict_code", pageDTO.getDict_code());

        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getDict_label()), "dict_label", pageDTO.getDict_label());
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getDict_value()), "dict_value", pageDTO.getDict_value());
        queryWrapper.like(StringUtils.isNotBlank(pageDTO.getDict_type()), "dict_type", pageDTO.getDict_type());
        return this.page(page, queryWrapper);
    }

    @Override
    public Object getInfo(Integer id) {
        return this.getById(id);
    }
}
